home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1994 December / 1994-12b.d64 / jump start (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  8KB  |  249 lines

  1. 1 goto 100
  2. 2 save"jump start.pgml",8
  3. 3 rem
  4. 4 rem
  5. 5 rem
  6. 6 verify"jump start.pgml",8
  7. 10 sys4096*9:                    rem re-enable metabasic after run-stop/restore
  8. 11 key 1,"[147]list":rem set keys-metabasic
  9. 12 rem
  10. 13 rem
  11. 14 key 2,"[147]llist"
  12. 15 rem
  13. 16 rem
  14. 17 key 3,"[147]run_"
  15. 18 rem
  16. 19 rem
  17. 20 key 4,"[147]": rem list section in devel
  18. 21 rem
  19. 22 rem
  20. 23 key 5,"[147]": rem list a ref section
  21. 24 rem
  22. 25 rem
  23. 26 key 6,"[147]find@"
  24. 27 rem
  25. 28 rem
  26. 29 key 7,"delete"
  27. 30 rem
  28. 31 rem
  29. 40 rem 10000 * print a pgm listing
  30. 42 rem 11000 * print screen routine
  31. 44 rem 11200 * display directory ****
  32. 46 rem 12000 * rtn to open/read file(s)
  33. 48 rem 12300 * decimal format routine
  34. 50 rem 12400 * 5 option sub menu
  35. 52 rem 13000 * generic shell sort
  36. 100 rem ************* numeric variables
  37. 101 a=0 :   rem tells sort # of entries
  38. 102 b=0 :   rem binary value of high middle of matrix
  39. 103 c=0 :   rem moving pointer to compare current position to fixed higher pos
  40. 104 d=0 :   rem 'fixed' higher pos pointer
  41. 110 tb=8:   rem tab value for options
  42. 120 sl=0:   rem choice of option
  43. 130 c1=.5:  rem constant needed @ 12300
  44. 132 c2=1:   rem constant nneded @ 12300
  45. 134 c3=100: rem constant needed @ 12300
  46. 140 na=0:   rem next address (12000)
  47. 141 nn=0:   rem counter (12000)
  48. 142 mx=0:   rem = max size of array (12000)
  49. 143 t =0:   rem receives ascii val of input
  50. 150 v=0 :   rem see 12302
  51. 151 fr=0:   rem see 12330 - fraction
  52. 152 lo=0:   rem see 12330
  53. 153 j=0 :   rem see 12320
  54. 200 rem ****  main menu options
  55. 210 tl$="program title here"
  56. 221 o1$="opt #1" : rem main menu opt 1
  57. 222 o2$="opt #2" : rem main menu opt 2
  58. 223 o3$="opt #3" : rem  etc.
  59. 224 o4$="opt #4"
  60. 225 o5$="not active"
  61. 226 o6$="not active"
  62. 227 o7$="not active"
  63. 228 o8$="not active"
  64. 229 o9$="calculate free space"
  65. 230 o0$="print screen"
  66. 239 rem *****  string variables
  67. 240 a$=" ": rem see 12000
  68. 245 n$=" ": rem see 12360-formatted dec
  69. 300 rem array dimensions defined here
  70. 310 dim m(20): rem sample array to be sorted - see 13000
  71. 400 rem **** main menu handler *****
  72. 410 print"[147]":printtab((40-len(tl$))/2);tl$:rem program title - centered
  73. 420 print
  74. 430 printtab(tb)"[144] 1.[146] ";o1$:print
  75. 435 printtab(tb)" 2.[146] ";o2$:print
  76. 440 printtab(tb)" 3.[146] ";o3$:print
  77. 445 printtab(tb)"[159] 4.[146] ";o4$:print
  78. 450 printtab(tb)"[156] 5.[146] ";o5$:print
  79. 455 printtab(tb)" 6.[146] ";o6$:print
  80. 460 printtab(tb)" 7.[146] ";o7$:print
  81. 465 printtab(tb)"[158] 8.[146] ";o8$:print
  82. 470 printtab(tb)"[144] 9.[146] ";o9$:print
  83. 475 printtab(tb)"10.[146] ";o0$:print
  84. 480 print"your selection, please";:input sl
  85. 485 if sl<1 or sl>10 then 400
  86. 489 rem label-     /     /     /     /     /     /     /     /     /     /
  87. 490 on sl goto 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 11000
  88. 498 rem line 489 allows 4 character labels above corresponding goto address to
  89. 499 rem   help trouble shooting & maint
  90. 500 rem initializing sub-routine 1
  91. 600 rem initializing sub-routine 2
  92. 700 rem initializing sub-routine 3
  93. 800 rem initializing sub-routine 4
  94. 900 rem initializing sub-routine 5
  95. 1000 rem **************** option 1
  96. 1004 print"[147]"
  97. 1005 print"you have chosen option 1"
  98. 1010 print"shift-return to main":wait653,1:goto400:rem code this option follows
  99. 2000 rem **************** option 2
  100. 2004 print"[147]"
  101. 2005 print"you have chosen option 2"
  102. 2010 print"shift-return to main":wait653,1:goto400:rem code this option follows
  103. 3000 rem **************** option 3
  104. 3004 print"[147]"
  105. 3005 print"you have chosen option 3"
  106. 3010 print"shift-return to main":wait653,1:goto400:rem code this option follows
  107. 4000 rem **************** option 4
  108. 4010 print"[147]"
  109. 4020 print"1 -sub opt 1-text":print
  110. 4025 print"2 -sub opt 2-text":print
  111. 4030 print"3 -sub opt 3-text":print
  112. 4035 print"4 -sub opt 4-text":print
  113. 4040 print"5 -exit":print
  114. 4050 input"enter your option #"; sl
  115. 4060 if sl <1 or sl >5 then goto 4010
  116. 4070 on sl goto 4100,4200,4300,4400,4500
  117. 4080 goto 4000
  118. 4100 rem ***** option 1
  119. 4105 print"you have chosen sub-opt 1"
  120. 4110 print"shift-return to sub ":wait653,1:goto4000:rem code follows
  121. 4199 goto4000
  122. 4200 rem ***** option 2
  123. 4205 print"you have chosen sub-opt 2"
  124. 4210 print"shift-return to main":wait653,1:goto4000:rem code follows
  125. 4299 goto4000
  126. 4300 rem ***** option 3
  127. 4305 print"you have chosen sub-opt 3"
  128. 4310 print"shift-return to main":wait653,1:goto4000:rem code follows
  129. 4399 goto4000
  130. 4400 rem ***** option 4
  131. 4405 print"you have chosen sub-opt 4"
  132. 4410 print"shift-return to main":wait653,1:goto4000:rem code follows
  133. 4499 goto4000
  134. 4500 rem ***** option 5 - exit to main menu
  135. 4505 print"you have chosen sub-opt 5"
  136. 4510 print"shift-return to main":wait653,1:goto400:rem code follows
  137. 5000 rem **************** option 5
  138. 5010 print"shift to return":wait653,1:goto400:rem code for this option follows
  139. 6000 rem **************** option 6
  140. 6010 print"shift to return":wait653,1:goto400:rem code for this option follows
  141. 7000 rem **************** option 7
  142. 7010 print"shift to return":wait653,1:goto400:rem code for this option follows
  143. 8000 rem **************** option 8
  144. 8010 print"shift to return":wait653,1:goto400:rem code for this option follows
  145. 9000 rem **************** free space
  146. 9005 print fre(0) - (fre(0)<0)*65536
  147. 9010 print"shift to return":wait653,1:goto400:rem code for this option follows
  148. 10000 rem *************** print listing
  149. 10010 open4,4:cmd4:list::print#4:close4:rem - with metabasic, use llist instead
  150. 10020 print"shift to return":wait653,1:goto400:rem code for option follows
  151. 11000 rem ******** print screen routine
  152. 11010 print"";       :rem clear screen
  153. 11020 open 3,3,3      :rem open screen as device 3 for input
  154. 11030 open 4,4,0      :rem open printer as dev 4 for output
  155. 11040 for i = 0 to1024:rem 1024 screen positions
  156. 11050 :get#3,a$       :rem get screen data
  157. 11060 :print#4,a$;    :rem print screen data
  158. 11070 next            :rem repeat 1024 times
  159. 11080 print#4         :rem final print
  160. 11090 close3          :rem close dev 3
  161. 11100 close4          :rem close dev 4
  162. 11110 goto400         :rem return main menu
  163. 11200 rem ******display directory ****
  164. 11210 open 2,8,0,"$":print"[147]"
  165. 11220 get#2,a$:get#2,a$
  166. 11230 get#2,l$:get#2,l$:ifst=64thenclose2:return
  167. 11240 get#2,lb$:get#2,hb$:ln=asc(lb$+chr$(0))+256*asc(hb$+chr$(0))
  168. 11250 print ln;
  169. 11260 get#2,a$:ifa$=""then printchr$(13);:goto11230
  170. 11270 printa$;:goto11260
  171. 12000 rem subrtn to open/read file(s)
  172. 12010 input"enter name of file";f$
  173. 12020 open 2,8,2,f$:nn=0
  174. 12040 get#2,a$:get$2,a$
  175. 12050 get#2,a$:if st<>0then 12110
  176. 12060 rem 31 '_' is carriage return
  177. 12070 t = asc(a$+"@")
  178. 12080 if t=31 then na=nn+1:goto12090
  179. 12085 if nn>mxthenprint"array not large enough":goto12120
  180. 12090 n$(nn)=n$(nn)+a$:nn=na
  181. 12100 goto12050
  182. 12110 n$(nn)=n$(nn)+chr$(31)
  183. 12120 close#2:return
  184. 12300 rem decimal format routine
  185. 12302 rem expects-v=value to round/prt
  186. 12303 rem expects-c1=.5,c2=1,c3=100
  187. 12304 rem returns-n$
  188. 12305 n$=str$(int(v*c3+c1)/c3)
  189. 12310 lo=len(n$)
  190. 12320 for j = 2 to lo
  191. 12330 :if mid$(n$,j,1)="." then fr = lo-j:j = lo
  192. 12340 next
  193. 12350 on fr+c2 goto 12370,12380,12390
  194. 12360 n$=left$(n$,lo-fr+2): goto12390
  195. 12370 n$=n$+".00":return
  196. 12380 n$=n$+"0"
  197. 12390 fr=0:return
  198. 12400 rem **** 5 option sub menu ****
  199. 12405 rem copy and renumber this code to any section of code where needed!
  200. 12406 rem add the correct option names  between the quotes in 12420 - 12440
  201. 12410 print"[147]"
  202. 12420 print"1 -sub opt 1-text":print
  203. 12425 print"2 -sub opt 2-text":print
  204. 12430 print"3 -sub opt 3-text":print
  205. 12435 print"4 -sub opt 4-text":print
  206. 12440 print"5 -exit":print
  207. 12450 input"enter your option #"; sl
  208. 12460 if sl <1 or >5 then goto 12400
  209. 12470 on sl goto 12500,12600,12700,12800,12900
  210. 12480 goto 400
  211. 12500 rem ***** option 1
  212. 12599 goto12400
  213. 12600 rem ***** option 2
  214. 12699 goto12400
  215. 12700 rem ***** option 3
  216. 12799 goto12400
  217. 12800 rem ***** option 4
  218. 12899 goto12400
  219. 12900 rem ***** option 5 - exit to main menu
  220. 12999 goto400
  221. 13000 rem generic shell sort
  222. 13001 rem routine expects a=the number of rows in the matrix (m) to be sorted
  223. 13002 rem by adjusting m(c) etc statements, can sort any field on any array
  224. 13003 rem
  225. 13004 print"[147]":                    rem clear screen
  226. 13005 b=1:                         rem find the value of the index which is
  227. 13006 rem just > a
  228. 13010 b=b*2:                       rem